import Vue from 'vue'
import App from './App.vue'
//引入路由
import router from '@/router'
//三级联动组件 --全局组件
import TypeNav from '@/components/TypeNav'
//轮播图组件 --全局组件
import Carousel from '@/components/Carousel'
//分页器组件 --全局组件
import Pagination from '@/components/Pagination'
//引入仓库
import store from '@/store'
// 统一接受api文件夹里的所有请求函数
import * as API from '@/api'
import {Button, MessageBox} from 'element-ui';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import VueLazyload from 'vue-lazyload'
import loadingImg from '@/assets/images/loading.gif'
//第一个参数全局组件名字，第二个参数：组件
Vue.component(TypeNav.name,TypeNav)
Vue.component(Carousel.name,Carousel)
Vue.component(Pagination.name,Pagination)
Vue.config.productionTip = false
Vue.component(Button.name,Button)
Vue.use(ElementUI);
// or with options
Vue.use(VueLazyload, {
  loading: loadingImg,
})
//引入mockServe.js
import '@/mock/mockServe'
//引入Swiper样式
import 'swiper/css/swiper.css'
import '@/plugins/validate'


new Vue({
  el:'#app',
  render: h => h(App),
  //注册路由，当书写router时，组件身上都拥有$route,$router属性
  router,
  //注册仓库:组件实例的身上会多一个$store属性
  store,
  beforeCreate(){
    Vue.prototype.$bus=this;
    Vue.prototype.$API=API;
    Vue.prototype.$msgbox = MessageBox;
    Vue.prototype.$alert = MessageBox.alert;
  }
})

